clear all 
set more off


cd "/home/user/h080700/private/S_Z/SIGE"


*use sige_data_06Q1_18Q1_mended_credit_cerved, clear

use CGR_2006q1_2019q1_with_credit, clear 


****==========================================================
*** 		inflation (ITALY) given to firms
****==========================================================
gen infl=2.2 if time==184
replace infl=2.3 if time==185
replace infl=2.3 if time==186
replace infl=1.9 if time==187

*** 2007
replace infl=1.9 if time==188
replace infl=1.8 if time==189
replace infl=1.7 if time==190
replace infl=2.3 if time==191

*** 2008
replace infl=3.1 if time==192
replace infl=3.6 if time==193
replace infl=4.0 if time==194
replace infl=3.6 if time==195

*** 2009
replace infl=1.4 if time==196
replace infl=1.2 if time==197
replace infl=-0.1 if time==198
replace infl=0.3 if time==199

*** 2010
replace infl=1.3 if time==200
replace infl=1.6 if time==201
replace infl=1.8 if time==202
replace infl=2.0 if time==203

*** 2011
replace infl=1.9 if time==204
replace infl=2.9 if time==205
replace infl=2.1 if time==206 /* */
replace infl=3.8 if time==207 /* */

*** 2012
replace infl=3.4 if time==208
replace infl=3.7 if time==209
replace infl=3.6 if time==210
replace infl=2.8 if time==211

*** 2013
replace infl=2.4 if time==212
replace infl=1.3 if time==213
replace infl=1.2 if time==214
replace infl=0.8 if time==215

*** 2014
replace infl=0.6 if time==216
replace infl=0.5 if time==217
replace infl=0   if time==218
replace infl=0.2 if time==219

*** 2015
replace infl=-0.5 if time==220
replace infl=-0.1 if time==221
replace infl=-0.1 if time==222
replace infl=-0.1 if time==223

*** 2016
replace infl=-0.1 if time==224
replace infl=-0.4 if time==225
replace infl=-0.2 if time==226
replace infl=-0.1 if time==227

*** 2017
replace infl=1 if time==228
replace infl=1.9 if time==229
replace infl=1.2 if time==230
replace infl=1.1 if time==231

*** 2018
replace infl=1.2 if time==232
replace infl=0.6 if time==233
replace infl=1.9 if time==234
replace infl=1.7 if time==235

*** 2019
replace infl=0.9 if time==236




label var infl "Inflation (ITALY) given to firms"

****==========================================================
*** 		inflation (ITALY) given to firms
****==========================================================
gen inflEURO=2.4 if time==184
replace inflEURO=2.4 if time==185
replace inflEURO=2.4 if time==186
replace inflEURO=1.6 if time==187

*** 2007
replace inflEURO=1.8 if time==188
replace inflEURO=1.9 if time==189
replace inflEURO=1.8 if time==190
replace inflEURO=2.6 if time==191

*** 2008
replace inflEURO=3.2 if time==192
replace inflEURO=3.3 if time==193
replace inflEURO=4.0 if time==194
replace inflEURO=3.2 if time==195

*** 2009
replace inflEURO=1.1 if time==196
replace inflEURO=0.6 if time==197
replace inflEURO=-0.7 if time==198
replace inflEURO=-0.1 if time==199

*** 2010
replace inflEURO=1.0 if time==200
replace inflEURO=1.5 if time==201
replace inflEURO=1.8 if time==202
replace inflEURO=1.9 if time==203

*** 2011
replace inflEURO=2.3 if time==204
replace inflEURO=2.8 if time==205
replace inflEURO=2.5 if time==206 
replace inflEURO=3.0 if time==207 /* */

*** 2012
replace inflEURO=2.6 if time==208
replace inflEURO=2.6 if time==209
replace inflEURO=2.4 if time==210
replace inflEURO=2.5 if time==211

*** 2013
replace inflEURO=2.0 if time==212
replace inflEURO=1.2 if time==213
replace inflEURO=1.6 if time==214
replace inflEURO=0.7 if time==215

*** 2014
replace inflEURO=0.8 if time==216
replace inflEURO=0.7 if time==217
replace inflEURO=0.4 if time==218
replace inflEURO=0.4 if time==219

*** 2015
replace inflEURO=-0.6 if time==220
replace inflEURO=0.0 if time==221
replace inflEURO=0.0 if time==222
replace inflEURO=0.0 if time==223

*** 2016
replace inflEURO=0.0 if time==224
replace inflEURO=-0.2 if time==225
replace inflEURO=0.2 if time==226
replace inflEURO=0.5 if time==227

*** 2017
replace inflEURO=1.8 if time==228
replace inflEURO=2.0 if time==229
replace inflEURO=1.3 if time==230
replace inflEURO=1.1 if time==231

*** 2018
replace inflEURO=1.3 if time==232
replace inflEURO=1.2 if time==233
replace inflEURO=2.1 if time==234
replace inflEURO=2.2 if time==235

*** 2019
replace inflEURO=1.4 if time==236


label var infl "Inflation (ITALY) given to firms"


***~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*** 			define treatments
***~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

gen treatment_old=(formdom==2)
replace treatment_old=1 if time<=209

tab time treatment_old, mis

*tab formdom_new if treatment_old==.
*gen treatment_new=treatment_old
*replace treatment_new=2 if (formdom_new==1) & treatment_new==.

label define Told 0 "Control" 1 "Treatment (past inflation)"
label values treatment_old Told

*label define Tnew 0 "Control" 1 "Treatment (past inflation)" 2 "Treatment (ECB target)"
*label values treatment_new Tnew



***~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*** 	define expectations in one variable
***~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

foreach var in it6 it12 it24 it48 {
gen `var'_all=`var'
replace `var'_all=`var'n if `var'==.
}

label var it6_all "inflation expectation: 6 month ahead"
label var it12_all "inflation expectation: 12 month ahead"
label var it24_all "inflation expectation: 24 month ahead"
label var it48_all "inflation expectation: 48 month ahead"



***~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*** 	define variables and labels
***~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

label var peso "Sampling weight"

label var setton5 "Indsutry"
label define setton5_lbl 1 "Manufacturing" 2 "Other industry" 3 "Trading" 4 "Other services" 5 "Construction"
label values  setton5 setton5_lbl

label var add "Number of employees"
gen lnL=log(add)*100 
label var lnL "LOG(Number of employees)*100"

label var export4 "Export share"
label define export4_lbl 1 "zero" 2 "up to 1/3" 3 "between 1/3 and 2/3" 4  "more than 2/3" 
label values  export4 export4_lbl


label var disit "factors affecting your business (next 3 months): changes in demand"
label var prsit "factors affecting your business (next 3 months): changes in your prices"
label var crsit "factors affecting your business (next 3 months): availablity/cost of credit"
* label var polit "factors affecting your business (next 3 months): uncertainty"
* label var tacam "factors affecting your business (next 3 months): exchange rate dynamics"
* label var prpet "factors affecting your business (next 3 months): oil price dynamics"

label var sitinv "conditions for investment now relative to 3 months ago"
label define sitinv_lbl 1 "worse" 2 "the same" 3 "better"
label values  sitinv sitinv_lbl


label var liquid "conditions for liquidity (next three months)"
label define liquid_lbl 1 "insufficient" 2 "sufficient" 3 "more than sufficient"
label values  liquid liquid_lbl

label var pretot "Total demand for your products (next 3 months)"
label define pretot_lbl 1 "Decrease" 2 "No change" 3 "Increase" 
label values  pretot pretot_lbl

label var sitcre "credit conditions for your company now relative to 3 motnhs ago"
label define sitcre_lbl 1 "Worse" 2 "No change" 3 "Better" 
label values  sitcre sitcre_lbl

label var dpre "Ave. change in your prices in the last 12 months"
label var dprez "Ave. change in your prices in the next 12 months"

label var occtot "Number of employees in the next 3 months"
label define occtot_lbl 1 "Lower" 2 "No change" 3 "Higher"
label values  occtot occtot_lbl

label var promig "Prob. of an improvement in Italy’s gen econ situation in next 3 months"
label define promig_lbl 1 "Zero" 2 "1-25%" 3 "26-50%" 4 "51-75%" 5 "76-99%" 6 "100%"
label values  promig promig_lbl

label var sitgen "Italy’s general economic situation now relative to 3 months ago"
label define sitgen_lbl 1 "Worse"  2 "Same" 3  "Better"
label values  sitgen sitgen_lbl

label var domtot "total demand for your products now relative to 3 months ago"
label define domtot_lbl 1  "Lower"  2 "Same" 3  "Higher"
label values  domtot domtot_lbl

label var sitimp5 "business conditions for your company: next 3 months"
label define sitimp5_lbl 1 "Much worse"   2 "Worse" 3 "Same" 4 "Better"  5 "Much better"
label values  sitimp5 sitimp5_lbl

label var invpre "investment next calendar year"
label define invpre_lbl 1 "Much lower"   2 "Little lower"  3 "Same" 4 "Little higher" 5 "Much higher"
label values  invpre invpre_lbl
 
 
duplicates drop firm_id time, force
 
compress
 
*cd "C:\Dropbox\CGR\temp_yg\workfiles"
save step001_credit_QJE, replace
